package com.soft.line.controller;

import com.soft.line.filter.HttpRequestUtil;
import com.soft.line.filter.UserTokenDto;
import com.soft.line.service.LoginService;
import com.soft.line.util.MP.AjaxResult;
import com.soft.line.util.exception.ResultData;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Description 小程序登录相关
 * @author wu.xueqiao on 2020/6/1.
 * @version 0.1
 */
@RestController
@RequestMapping("/applet")
public class MpLoginController {

    @Autowired
    private LoginService loginService;
    @Autowired
    HttpServletRequest request;


    @PostMapping("/autoLogin")
    public AjaxResult autoLogin(@RequestBody Map<String,String> map){
        return loginService.autoLogin(map.get("code"));
    }

    @PostMapping("/bindUserInfo")
    public AjaxResult bindUserInfo(@RequestBody Map<String, String> paraMap) {
        return loginService.bindUserInfo(paraMap);
    }

    @PostMapping("/getUserInfo")
    public AjaxResult getUserInfo(@RequestBody Map<String, String> paraMap) {
        return loginService.getUserInfo(paraMap);
    }

    /**
     * 修改密码
     * @param paraMap
     * @return
     */
    @PostMapping("/updatePassword")
    public AjaxResult updatePassword(@RequestBody Map<String, Object> paraMap){
        return loginService.updatePassword(paraMap);
    }

    /**
     * 解除绑定
     *
     * @return
     */
    @PostMapping("/untie")
    public AjaxResult untie(){
        return loginService.untie();
    }
}
